<<<<<<< HEAD
<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"E:\phpstudy_pro\WWW\nmg03\public/../application/admin\view\homemenus\update.html";i:1704427146;}*/ ?>
=======
<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"E:\phpstudy_pro\WWW\nmg03\public/../application/admin\view\homemenus\update.html";i:1704698633;}*/ ?>
>>>>>>> shool
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title><?php echo $setting['webname']; ?> - 修改前台导航</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link rel="shortcut icon" href="/public/static/favicon.ico"> <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        /*图标选择*/
        .fa-hover-active{

        }
        .fa-hover-active a{
            background-color: #1d9d74;
            text-decoration: none;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: block;
            line-height: 32px!important;
            height: 32px!important;
            padding-left: 10px;
            border-radius: 4px;
            color:#fff !important;
        }
        .fa-hover-active i{
            color:#fff;
            vertical-align: -6px;
            font-size:30px !important;
        }
    </style>

</head>

<body class="gray-bg">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2>修改设备信息</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="<?php echo url('Admins/admin'); ?>">主页</a>
                </li>
                <li>
                    <strong>修改前台导航</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
             <div class="col-sm-12">
			 
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>修改前台导航</h5>
					</div>
                    <div class="ibox-content">
<<<<<<< HEAD
                        <form class="form-horizontal">
=======
                        <form class="form-horizontal" id="form1">
>>>>>>> shool

                            <div class="form-group">
                                <label class="col-sm-2 control-label">栏目名称：</label>
                                <div class="col-sm-4">
<<<<<<< HEAD
                                    <input type="text" placeholder="栏目名称" id="title" value="<?php echo $data['title']; ?>" class="form-control">
=======
                                    <input type="hidden" name="id" value="<?php echo $data['id']; ?>">
                                    <input type="text" placeholder="栏目名称" id="title" value="<?php echo $data['title']; ?>" name="title" class="form-control">
>>>>>>> shool
                                </div>
                                <div class='col-sm-6'></div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">所属栏目：</label>
                                <div class="col-sm-4">
                                    <select class="form-control m-b" name="pid" id="pid">
                                        <option value="0">顶级栏目</option>
                                        <?php foreach($list as $vo): ?>
                                        <option value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
<<<<<<< HEAD
                            
=======

>>>>>>> shool
                            <!--图片-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">主图（本地上传）：</label>
                                <div class="col-sm-6">
                                    <input type="button" class="btn btn-success" value="已上传的图片" id="selffile">
                                    <button type="button" class="btn btn-info" id="test1">上传图片</button>
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" id="demo1" style='max-width:100%'>
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                                <div class='col-sm-4'></div>
                            </div>
<<<<<<< HEAD

                            <div class="form-group">
                                <label class="col-sm-2 control-label">栏目地址：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入栏目地址" id="href" class="form-control" value="<?php echo $data['href']; ?>">
=======
                            <!--导航地址-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">栏目地址：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入栏目地址" id="href" class="form-control" name="href" value="<?php echo $data['href']; ?>">
>>>>>>> shool
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <div class="form-group">
<<<<<<< HEAD
                                <label class="col-sm-2 control-label">排序：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入排序数字" id="sort" class="form-control" value="<?php echo $data['sort']; ?>">
=======
                                <label class="col-sm-2 control-label">打开方式：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入打开方式" list="opentype_list" id="opentype" value="<?php echo $data['opentype']; ?>" class="form-control" name="opentype">
                                    <datalist id="opentype_list">
                                        <option value="navigate"/>
                                        <option value="switchTab"/>
                                        <option value="redirect"/>
                                        <option value="navigateBack"/>
                                    </datalist>
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <!--排序-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="请输入排序数字" id="sort" name="sort" class="form-control" value="<?php echo $data['sort']; ?>">
>>>>>>> shool
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-9">
                                    <button class="btn btn-sm btn-info" type="button" id="adds">保 存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
		</div>
	</div>
    <link rel="stylesheet" href="/public/static/admin/css/imglist.css">
    <!--弹出已上传的图片-->
    <div class="layer_notive" >
        <ul id="imglist"></ul>
        <div style="clear:both"></div>
    </div>
    <!-- 全局js -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/static/admin/layui/layui.js"></script>
    <script src="/public/static/admin/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>

    <script>
        $("input:radio[value='<?php echo $data['status']; ?>']").attr("checked",true);
        $("#pid option[value='<?php echo $data['pid']; ?>']").attr("selected",true);

        $("#status option[value='<?php echo $data['status']; ?>']").prop("selected",true);
        $imgpath = "/public/static/admin/uploads/navigatorImage/"
        $("#demo1").attr("src",$imgpath+'<?php echo $data['icon']; ?>');

        layui.use('upload', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer,upload = layui.upload;
            var photo = "<?php echo $data['icon']; ?>";
            //点击提交
            $("#adds").click(function(){
<<<<<<< HEAD
                $.post("<?php echo url('Homemenus/edit'); ?>",{id:<?php echo $data['id']; ?>,title:$("#title").val(),pid:$("#pid").val(),icon:photo,href:$("#href").val(),sort:$("#sort").val()},function(data){
=======
                var data = {}
                $("#form1").serializeArray().forEach(v=>{
                    data[v.name] = v.value
                });
                data['icon'] = photo
                $.post("<?php echo url('Homemenus/edit'); ?>",data,function(data){
>>>>>>> shool
                    top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                        if(data.url){
                            window.location.href = data.url;
                        }
                    });
                })
            });
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                ,url: "<?php echo url('Homemenus/upload'); ?>"
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code == 0){
                        return top.layer.msg('上传失败',{shade:0.5});
                    }else if(res.code){
                        //上传成功
                        photo = res.photo;
                        return top.layer.msg('上传成功',{shade:0.5});
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });

            //显示本地图片
            $("#selffile").click(function () {
                $.post("<?php echo url('Base/getmyfiles'); ?>",{path:$imgpath},function(data){
                    console.log(data);
                    var str = "";
                    for( i in data.msg){
                        str += "<li><img src='"+$imgpath+data.msg[i]+"' class='imglist' data-photo='"+data.msg[i]+"' onclick='changecss(this)' alt=''><div class='del_div'><i class='fa fa-close del' title='删除' data-path='"+$imgpath+data.msg[i]+"'></i></div></li>";
                    }
                    $("#imglist").html(str);
                    //页面层
                    layer.open({
                        type: 1,
                        skin: false, //加上边框
                        title: "已上传的图片",
                        area: ['700px', '600px'], //宽高
                        btn:["确认","取消"],
                        content: $(".layer_notive"),  //调到新增页面
                        yes:function(){
                            var newImgsrc = $(".active").attr("src");
                            var newImgname = $(".active").data("photo");
                            $('#demo1').attr('src', newImgsrc); //图片链接（base64）
                            $('#demo1').attr('width','100%');
                            photo = newImgname;
                            layer.closeAll();
                        }
                    });
                });
            });
            //删除图片
            $("#imglist").on("click",".del",function(v){
                $this = $(this);
                //页面层
                top.layer.msg('你确定要删除这张图片吗?', {
                    time: 20000, //20s后自动关闭
                    shade:0.5,
                    btn: ['确定', '取消'],
                    yes:function(){
                        var data  = {
                            "path" : $this.data("path")
                        }
                        $.post("<?php echo url('Base/delfile'); ?>",data,function(data){
                            top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                                $.post("<?php echo url('Base/getmyfiles'); ?>",{path:$imgpath},function(data) {
                                    console.log(data);
                                    var str = "";
                                    for (i in data.msg) {
                                        str += "<li><img src='"+$imgpath + data.msg[i] + "' class='imglist' data-photo='" + data.msg[i] + "' onclick='changecss(this)' alt=''><div class='del_div'><i class='fa fa-close del' title='删除' data-path='"+$imgpath + data.msg[i] + "'></i></div></li>";
                                    }
                                    $("#imglist").html(str);
                                });
                            });
                        });
                    }
                });
            });

        });

        //点击图片选择图片
        function changecss(obj){
            $(".imglist").removeClass("active");
            $(obj).addClass("active");
        }
    </script>
    
    

</body>

</html>
